
import 'package:wch/utils/log_utils.dart';
import 'package:wch/utils/time_utils.dart';

import '../model/patient_list.dart';

class UserWrapHelper {

}

class UserWrapModel {
  String? name;
  String? mobile;
  String? sex;
  String? date;
  String? deviceId;
  String? deviceNumber;
  String? createTime;
  String? doctor;
  int? age;
  String? userId;
}

UserWrapModel userWrap(PatientListDataData data) {
  UserWrapModel model = UserWrapModel();
  for(int j = 0; j < data.list!.length; j ++) {
    PatientListDataDataList user = data.list![j];
    LogUtils.log('text=${user.text}');
    if (user.name == '姓名') {
      model.name = user.text;
      model.userId = user.sickPersonId;
    } else if (user.name == '性别') {
      model.sex = user.text;
    } else if (user.name == '手机号') {
      model.mobile = user.text;
    } else if (user.name == '出生日期') {
      model.date = user.text;
      model.age = TimeUtils.calculateAge(user.text!);
    } else if (user.name == '年龄') {
      // model.age = (user.text != null && user.text!.isNotEmpty) ? int.parse(user.text!) : 0;
    }
  }
  return model;
}